#include "configSet.h"
#include "QSettings"
#include "QFile"
#include "QTextStream"
#include <QDebug>

ConfigSet::ConfigSet(QString iniFile)
{
    m_iniFile = iniFile;
}

ConfigSet::~ConfigSet()
{

}

bool ConfigSet::readConfig()
{
    QFile file(m_iniFile);
    if(!file.open(QIODevice::ReadOnly| QIODevice::Text)){
        qDebug()<<"open error";
        return false;
    }
    QTextStream in(&file);
    while(!in.atEnd()){
        QString str = in.readLine();
        m_vector.append(str);
        qDebug()<<str;
    }
    file.close();
    return true;
}

bool ConfigSet::saveConfig()
{
    QFile file(m_iniFile);
    if(!file.open(QIODevice::ReadWrite| QIODevice::Text)){
        qDebug()<<"open error";
        return false;
    }
    QTextStream in(&file);
    for(QVector<QString>::Iterator it = m_vector.begin();it!=m_vector.end();it++){
        in<<*it<<"\n";
        qDebug()<<*it;
    }
    file.close();
    return true;
}

